﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using NJamb.Parser.SpecificationBuilders;
using NJamb.Specifications.Delta;
using NJamb.Specifications.Simple;
using NUnit.Framework;
using Stile.Patterns.SelfDescribingPredicates;
#endregion

namespace NJamb.NUnit
{
    public static class SpecificationExtensions
    {
        public static void AsPrecondition<TSubject, TDeltaSpecificationBuilder, TEvaluation>(
            this ISimpleSpecification<TSubject, TDeltaSpecificationBuilder, TEvaluation> specification)
            where TDeltaSpecificationBuilder : class, ICanThrow<IDeltaSpecification> where TEvaluation : IEvaluation
        {
            IEvaluation evaluation = specification.Evaluate();
            if (!evaluation.Success)
            {
                Assert.Fail(evaluation.Reason);
            }
        }
    }
}
